
function e() {

    /*获取所有li*/
    let li = document.querySelectorAll(".ty");

    /*获取总价格*/
    let zjg = document.querySelector(".zj");

    let allsum = 0;

    for (let i = 0; i < li.length; i++) {

        /*获取单价*/
        let price = li[i].children[2].children[0].innerHTML;

        /*获取数量*/
        let num = li[i].children[3].value;

        /*小计*/
        let total = li[i].children[4].children[0].innerHTML = price * num;
        allsum += total;

    }
    zjg.innerHTML = allsum.toFixed(2);

}
e();


let ipt = document.querySelectorAll(".ipt");
for(var j = 0; j < ipt.length; j++){
    ipt[j].addEventListener("change",e);
}

let del = document.querySelectorAll(".delete");
for (var k = 0 ; k <del.length; k++){
    del[k].addEventListener("click",function(){
        this.parentNode.parentNode.removeChild(this.parentNode);

        document.querySelector("h4 span").innerHTML = Number(document.querySelector("h4 span").innerHTML) - 1;

        e();
    })
}














